![require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages](https://cdn.sanity.io/images/cgdhsj6q/production/be8ab80c8efa5907bc341c6fefe9aa20d239d890-1600x1097.png?w=400&fit=max&auto=format)
Security News
require(esm) Backported to Node.js 20, Paving the Way for ESM-Only Packages
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
@loaders.gl/schema
Advanced tools
@loaders.gl/schema is a library that provides utilities for working with data schemas, including parsing, validation, and transformation of structured data. It is part of the larger loaders.gl suite, which is designed for loading and processing large datasets efficiently.
Schema Parsing
This feature allows you to define and parse a schema for structured data. The code sample demonstrates how to create a new schema with fields for 'id', 'name', and 'age'.
const { Schema } = require('@loaders.gl/schema');
const schema = new Schema({
fields: [
{name: 'id', type: 'integer'},
{name: 'name', type: 'string'},
{name: 'age', type: 'integer'}
]
});
console.log(schema);
Data Validation
This feature allows you to validate data against a defined schema. The code sample shows how to validate an object with 'id', 'name', and 'age' fields against the schema.
const { Schema, validate } = require('@loaders.gl/schema');
const schema = new Schema({
fields: [
{name: 'id', type: 'integer'},
{name: 'name', type: 'string'},
{name: 'age', type: 'integer'}
]
});
const data = { id: 1, name: 'John Doe', age: 30 };
const isValid = validate(schema, data);
console.log(isValid);
Data Transformation
This feature allows you to transform data to match the types defined in the schema. The code sample demonstrates transforming string values to their respective types as defined in the schema.
const { Schema, transform } = require('@loaders.gl/schema');
const schema = new Schema({
fields: [
{name: 'id', type: 'integer'},
{name: 'name', type: 'string'},
{name: 'age', type: 'integer'}
]
});
const data = { id: '1', name: 'John Doe', age: '30' };
const transformedData = transform(schema, data);
console.log(transformedData);
AJV (Another JSON Schema Validator) is a popular JSON schema validator that provides fast and flexible validation of JSON data. It supports JSON Schema draft-07 and is highly configurable. Compared to @loaders.gl/schema, AJV is more focused on JSON schema validation and offers extensive features for this purpose.
Joi is a powerful schema description language and data validator for JavaScript. It allows you to create blueprints for JavaScript objects to ensure validation. Joi is more focused on validation and schema description, whereas @loaders.gl/schema also includes data transformation capabilities.
Yup is a JavaScript schema builder for value parsing and validation. It is similar to Joi but is often used in React applications for form validation. Yup provides a more modern API and is highly flexible. Compared to @loaders.gl/schema, Yup is more focused on form validation and schema building.
This module contains:
loaders.gl is a collection of framework-independent 3D and geospatial parsers and encoders.
Please visit the website.
FAQs
Table format APIs for JSON, CSV, etc...
The npm package @loaders.gl/schema receives a total of 204,622 weekly downloads. As such, @loaders.gl/schema popularity was classified as popular.
We found that @loaders.gl/schema demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
require(esm) backported to Node.js 20, easing the transition to ESM-only packages and reducing complexity for developers as Node 18 nears end-of-life.
Security News
PyPI now supports iOS and Android wheels, making it easier for Python developers to distribute mobile packages.
Security News
Create React App is officially deprecated due to React 19 issues and lack of maintenance—developers should switch to Vite or other modern alternatives.